﻿using Prism.Commands;
using Prism.Regions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Zhy.PrismRegion.Composite.ViewModels
{
    public class MainWindowViewModel
    {
        /// <summary>
        /// 全部保存按钮
        /// 复合命令-可以把多个命令整合到一起
        /// </summary>
        public CompositeCommand AllSaveCommand { get; set; }
        /// <summary>
        /// 全部关闭按钮
        /// 复合命令-可以把多个命令整合到一起
        /// </summary>
        public CompositeCommand AllCloseCommand { get; set; }
        /// <summary>
        /// 显示页面按钮
        /// </summary>
        public DelegateCommand<string> ShowPageCommand { get; set; }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="regionManager">区域管理器注册</param>
        /// <param name="composite">复合命令注册</param>
        public MainWindowViewModel(IRegionManager regionManager,
            CompositeCommand composite,AllSaveCompositeCommand allSaveComposite)
        {
            ShowPageCommand = new DelegateCommand<string>( p =>
            {
                regionManager.RequestNavigate("Region1", "ViewA");
                regionManager.RequestNavigate("Region2", "ViewB");
            });

            AllSaveCommand = allSaveComposite; // 实例化复合命令
            AllCloseCommand = composite; // 实例化复合命令
            //AllSaveCommand.RegisterCommand(ShowPageCommand);
        }
    }
}
